<?php
	$obj=new Request();
	if ( strcasecmp( @ $_SERVER['REQUEST_METHOD'], 'POST' ) == 0 )
	{
		//print_r($_POST['delete']);
		$arr=$_POST['delete'];
		$s=arrToList($arr,",");
		foreach($arr as $key => $val)
		{
			$obj->RequestID=$val;
			$obj->delete($conn);
		}
		linkto("?module=$module");	
	}
	$requestid=$_GET['requestid'];
	if($requestid!="")
	{
		$obj->loadByKey($requestid);
		if($obj->Status==0)
			$obj->Status=1;
		else
			$obj->Status=0;
		$obj->update($conn);
		linkto("?module=$module");
	}
?>
<form name="f" action="" method="post" enctype="multipart/form-data">
<div class="ContentTitle">
    <div class="left" style="padding-top:8px"><?php echo $objModule->ModuleName?></div>
    <div class="CMSButton right">
        <?php
        if($objUserType->isAllow($objModule->ModuleID,2)!=-1)
		{
		?>
                <a href="#" onclick="fsubmit()">Xóa</a>
		<?php
		}
		?>
    </div>    
    <div class="clear"></div>
</div>
<ul id="ContentTabs" class="shadetabs">
    <!--
    <li><a class="selected" onclick="ShowHideDiv('Tab',1,2)">General Information</a></li>
    <li><a onclick="ShowHideDiv('Tab',1,2)">Account Information</a></li>
    -->
</ul>       

<div id="Tab1" class="TabContainer" style="display:block">
<!-------------CONTENT OF EACH MODULE ---------------------------->
<table width="100%" class="list">
	<thead>
   	  <tr class="thead">
      	  <td class="tdright" width="33">
          <input type="checkbox" onclick="$('input[name*=\'delete\']').attr('checked', this.checked);"/>
          </td>
          <td class="tdleft">Name</td>
          <td class="tdleft">Email</td>
          <td class="tdleft">Phone</td>
          <td class="tdleft">Country</td>
          <td class="tdleft">Comment</td>
          <td class="tdleft">Product</td>
          <td class="tdleft">Status</td>
          <td class="tdleft">Date</td>
      </tr>
    </thead>
    <tbody>
<?php
	
	$where=" ORDER BY `LastUpdate` DESC";
	$obj=new Request();
	$data=array();
	$data=$obj->travel($where);
	
	
	/*******Start Paging*****************************/
	$page = $_GET['page'];				
	$limit = 20; 
	$total = count($data); 
	// work out the pager values 
	$pager  = Pager::getPagerData($total, $limit, $page); 
	$offset = $pager->offset; 
	$limit  = $pager->limit; 
	$page   = $pager->page;
	/*******Break paging*******************************/
	for($i=$offset;$i<$offset+$limit && $data[$i]!="";$i++)
	{
		$obj->loadByKey($data[$i]);
		$class="even";
		if($i%2!=0)
			$class="odd";
?>
    	<tr class="<?php echo $class?>">
            <td class="tdright">
            <input type="checkbox" name="delete[<?php echo $i?>]" value="<?php echo $obj->RequestID?>"/>
            </td>
            <td class="tdleft"><?php echo $obj->Name?></td>
            <td class="tdleft"><?php echo $obj->Email?></td>
            <td class="tdleft"><?php echo $obj->Phone?></td>
            <td class="tdleft"><?php echo $obj->Country?></td>
            <td class="tdleft"><?php echo $obj->Comment?></td>
            <td class="tdleft"><?php echo $obj->ProductID?></td>
            <td class="tdleft">
                <input type="checkbox" name="Status" value="1" <?php if($obj->Status==1) echo "checked"?> onchange="linkto('?module=request&requestid=<?php echo $obj->RequestID?>')")"/>
            </td>
            <td class="tdleft"><?php echo $obj->LastUpdate?></td>
        </tr>
<?php
	}
?>
    </tbody>
</table>
<?php
	include("modules/page.php");
?>
<!-------------END CONTENT OF EACH MODULE ---------------------------->
</div>
</form>
<script language="javascript">
from=document.f
function fsubmit()
{
	anser=confirm('Are you sure delete !')
	if(anser==true)
	{
		from.submit()
	}
}
</script>